package com.producteev4j.services;

import com.producteev4j.exceptions.ProducteevException;
import com.producteev4j.exceptions.ProducteevServiceException;
import com.producteev4j.exceptions.ProducteevSignatureException;
import com.producteev4j.model.response.*;

import java.util.Date;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: jcarrey
 * Date: 14/05/11
 * TimeImpl: 13:27
 * To change this template use File | Settings | File Templates.
 */
public interface ProducteevService {

    public class ProducteevSortByType {
        public static final int DEADLINE = 1;
        public static final int MANAGER = 2;
        public static final int LABELS = 3;
        public static final int TIME_LAST_CHANGE = 4;
        public static final int WORKSPACE = 5;
        public static final int PRIORITY = 6;
        public static final int TITLE = 7;
        public static final int TIME_CREATED = 8;
    }

    /**
     * Get server time
     *
     * @return
     * @throws ProducteevException
     */
    Date getTime() throws ProducteevException;

    /**
     * Get user info
     *
     * @param userToken
     * @param idCollegue
     * @return
     * @throws ProducteevException
     */
    User getUser(String userToken, String idCollegue) throws ProducteevException;

    /**
     * Works
     *
     * @param email
     * @param password
     * @return
     * @throws ProducteevSignatureException
     * @throws ProducteevServiceException
     * @throws ProducteevException
     */
    UserLogin userLogin(String email, String password) throws ProducteevSignatureException, ProducteevServiceException, ProducteevException;

    /**
     * Not tested
     *
     * @param facebookId
     * @param facebookOauthToken
     * @return
     * @throws ProducteevException
     */
    UserLogin userFacebookLogin(long facebookId, String facebookOauthToken) throws ProducteevException;

    /**
     * Set default dashboard
     *
     * @param userToken
     * @param idDashboard
     * @return
     * @throws ProducteevException
     */
    User setDefaultDashboard(String userToken, long idDashboard) throws ProducteevException;

    /**
     * getColleagues of userLogged
     *
     * @param userToken
     * @return
     * @throws ProducteevException
     */
    List<? extends UserWrapper> getColleagues(String userToken) throws ProducteevException;

    /**
     * SignupUser
     *
     * @param firstName
     * @param lastName
     * @param password
     * @param email
     * @param timeZone
     * @param fbuid     - (Optional)
     * @return
     * @throws ProducteevException
     */
    User signupUser(String firstName, String lastName, String password, String email,
                    String timeZone, Long fbuid) throws ProducteevException;


    /**
     * Set sort by type
     * @param userToken
     * @param sortByType ProducteevService.ProducteevSortByType.*****
     * @return
     * @throws ProducteevException
     */
    User setSortByType(String userToken, int sortByType) throws ProducteevException;


    /**
     * @param userToken
     * @param title             - (Mandatory)
     * @param idResponsible     - (Optional)
     * @param idDashboard       - (Optional)
     * @param deadline          - (Optional)
     * @param allDay            - (Optional)
     * @param reminder          - (Optional)
     * @param status            - (Optional)
     * @param star              - (Optional)
     * @param repeatinginterval - (Optional)
     * @param repeatingValue    - (Optional)
     * @param idLabel           - (Optional)
     * @return
     * @throws ProducteevException
     */
    Task createTask(String userToken, String title, Long idResponsible,
                    Long idDashboard, String deadline, Integer allDay, Integer reminder, Integer status,
                    Integer star, String repeatinginterval, Integer repeatingValue, Long[] idLabel) throws ProducteevException;


    /**
     * Get tasks
     *
     * @param userToken
     * @param since     - (Optional) - Task since this date
     * @param dashboard - Optional dashboard
     * @param page      - Optional , if not 200 first tasks
     * @return
     * @throws ProducteevException
     */
    List<? extends TaskWrapper> getTasks(String userToken, Date since, Long dashboard, Integer page) throws ProducteevException;

    /**
     * Get task by Id
     *
     * @param userToken
     * @param taskId
     * @return
     * @throws ProducteevException
     */
    public Task getTask(String userToken, long taskId) throws ProducteevException;

    /**
     * Access Control List of Task
     * @param userToken
     * @param idTask
     * @return
     * @throws ProducteevException
     */
    public List<? extends UserWrapper> getTaskAccessControlList(String userToken, long idTask) throws ProducteevException;

    public boolean deleteTask(String userToken, long idTask) throws ProducteevException;

    /**
     * unset the deadline
     *
     * @param userToken
     * @param idTask
     * @return
     * @throws ProducteevException
     */
    public Task unsetTaskRepeating(String userToken, long idTask) throws ProducteevException;


    /**
     * Set task repeating value
     * @param userToken
     * @param idTask
     * @param repeatingInterval - day(s), weekday(s), week(s), month(s) and year(s)
     * @param repeatingValue    - (Optional) Number of days
     * @return
     * @throws ProducteevException
     */
    public Task setTaskRepeating(String userToken, long idTask, String repeatingInterval, Integer repeatingValue) throws ProducteevException;

    /**
     * Set task reminder (email/..)
     * @param userToken
     * @param idTask
     * @param idReminder - (0 = "None", 1 = "5 minutes before", 2 = "15 minutes before", 3 = "30 minutes before", 4 = "1 hour before", 5 = "2 hours before", 6 = "1 day before", 7 = "2 days before", 8 = "on date of event")
     * @return
     * @throws ProducteevException
     */
    public Task setTaskReminder(String userToken, long idTask, int idReminder) throws ProducteevException;

    /**
     * unset the deadline
     *
     * @param userToken
     * @param idTask
     * @return
     * @throws ProducteevException
     */
    public Task unsetTaskDeadline(String userToken, long idTask) throws ProducteevException;


    /**
     * set Task deadline
     * @param userToken
     * @param idTask
     * @param deadline
     * @param allDay    =1 -> deadline ignored, =0 -> the deadline
     * @return
     */
    public Task setTaskDeadline(String userToken, long idTask, Date deadline, boolean allDay) throws ProducteevException;

    /**
     * unset task responsible
     * @param userToken
     * @param idTask
     * @param idResponsible - responsible
     * @return
     * @throws ProducteevException
     */
    public Task unsetTaskResponsible(String userToken, long idTask, long idResponsible) throws ProducteevException;

    /**
     * set task responsible
     * @param userToken
     * @param idTask
     * @param idResponsible - Number of stars from 0 to 5
     * @return
     * @throws ProducteevException
     */
    public Task setTaskResponsible(String userToken, long idTask, long idResponsible) throws ProducteevException;

    /**
     * sets star number to task
     *
     * @param userToken
     * @param idTask
     * @param stars     - Number of stars from 0 to 5
     * @return
     * @throws ProducteevException
     */
    public Task setTaskStars(String userToken, long idTask, int stars) throws ProducteevException;

    /**
     * set title for task
     * @param userToken
     * @param idTask
     * @param title
     * @return
     * @throws ProducteevException
     */
    public Task setTaskTitle(String userToken, long idTask, String title) throws ProducteevException;

    /**
     * Set status of task
     * @param userToken
     * @param idTask
     * @param status
     * @return
     * @throws ProducteevException
     */
    Task setTaskStatus(String userToken, long idTask, int status) throws ProducteevException;

    /**
     * Returns 200 tasks
     *
     * @param userToken
     * @param since
     * @param dashboard
     * @param page      - Not yet used (See documentation)
     * @return
     * @throws ProducteevException
     */
    public List<? extends TaskWrapper> getArchivedTasks(String userToken, Date since, Long dashboard, Integer page) throws ProducteevException;

    List<? extends TaskWrapper> getMyTeamTasks(String userToken, Date since, Long dashboard, Integer page) throws ProducteevException;

    List<? extends TaskWrapper> getMyTasks(String userToken, Date since, Long dashboard, Integer page) throws ProducteevException;

    List<? extends LabelWrapper> getTaskLabels(String userToken, long idTask) throws ProducteevException;

    Task changeTaskLabels(String userToken, long idTask, Long[] idLabels) throws ProducteevException;

    // List<? extends UserWrapper> getTaskUserList(String userToken, long idTask) throws ProducteevException;

    public Task setTaskWorkspace(String userToken, long idTask, long idDashboard) throws ProducteevException;

    Note getNote(String userToken, long idNote) throws ProducteevException;

    List<? extends NoteWrapper> getTaskNotes(String userToken, long idTask, Date since) throws ProducteevException;

    public List<? extends ActivityWrapper> getTaskActivity(String userToken, long idTask, Integer page) throws ProducteevException;

    public Activity getActivity(String userToken, long idActivity) throws ProducteevException;

    public boolean deleteNote(String userToken, long idNote) throws ProducteevException;

    public Note createNote(String userToken, long idTask, String message) throws ProducteevException;


    Label getLabel(String userToken, long idLabel) throws ProducteevException;

    List<? extends LabelWrapper> getLabels(String userToken, long idDashboard, Date since, Integer page) throws ProducteevException;

    Label createLabel(String userToken, long idDashboard, String title) throws ProducteevException;

    boolean deleteLabel(String userToken, long idLabel) throws ProducteevException;

    List<? extends TaskWrapper> getTasksWithLabel(String userToken, long idLabel, Integer page) throws ProducteevException;

    Label setLabelTitle(String userToken, long idLabel, String title) throws ProducteevException;


    public List<? extends ActivityWrapper> getActivities(String userToken, Long idDashboard, Long lastId, Long page) throws ProducteevException;

    public List<? extends ActivityWrapper> getNotifications(String userToken, Long idDashboard, Long lastId, Long page) throws ProducteevException;

    public List<? extends ActivityWrapper> setNotificationRead(String userToken, long idDashboard, long lastId) throws ProducteevException;


    DashBoard createDashboard(String userToken, String title) throws ProducteevException;

    DashBoard getDashboard(String userToken, long idDashboard) throws ProducteevException;

    List<? extends DashBoardWrapper> getDashboards(String userToken, Date since, Integer page) throws ProducteevException;

    List<? extends UserWrapper> getDashboardAccess(String userToken, long idDashboard) throws ProducteevException;

    DashBoard leaveOrDelegateDashboard(String userToken, long idDashboard, Long idUser, Long idDelegate) throws ProducteevException;

    DashBoard setTitle(String userToken, long idDashboard, String title) throws ProducteevException;

    /*
     * set value of label_manager_auto
     *
     * @param transport
     * @param idDashboard
     * @param value       - 0 = DEACTIVATED, 1 = ACTIVATED
     * @return
     */
    /* TODO Wrong value always returned
    DashBoard setSmartLabels( String userToken, long idDashboard, int value)throws ProducteevException;
    */

    boolean deleteDashboard(String userToken, long idDashboard) throws ProducteevException;

    List<? extends TaskWrapper> getDashboardTasks(String userToken, long idDashboard, Date since, Integer page) throws ProducteevException;

    /**
     * Confirm invitation to dashboard
     *
     * @param idDashboard
     * @return
     */
    DashBoard confirmInvitation(String userToken, long idDashboard) throws ProducteevException;

    DashBoard refuseInvitation(String userToken, long idDashboard) throws ProducteevException;

    DashBoard inviteUserById(String userToken, long idDashboard, long idUserTo) throws ProducteevException;

    DashBoard inviteUserByEmail(String userToken, long idDashboard, String email) throws ProducteevException;


    List<? extends DashBoardWrapper> getDashboardsToUpgrade(String userToken) throws ProducteevException;

    boolean needsUpgrade(String userToken, long idDashboard) throws ProducteevException;

}
